import { cloud, default as request } from '@/framework/utils/request'

// 获取列表数据
export function getGoods(query) {
  return request({
    url: `${cloud.mall}/goods/backstagePageList`,
    method: 'get',
    params: query
  })
}

// 获取商品属性
export function getGoodsType(query) {
  return request({
    url: `${cloud.mall}/tDicDictionary/getDicList`,
    method: 'get',
    params: query
  })
}

// 新增列表数据
export function addGoods(data) {
  return request({
    url: `${cloud.mall}/goods/insert`,
    method: 'post',
    data
  })
}

// 更新属性
export function updateGoodsAttr(query) {
  return request({
    url: `${cloud.mall}/goods/updateAttributesById`,
    method: 'get',
    params: query
  })
}

// 更改商品状态
export function updateGoodsStatus(data) {
  return request({
    url: `${cloud.mall}/goods/updateStateByIds`,
    method: 'post',
    data
  })
}

/**
 * @Description: 商品分类 /tMgdCategory/list
 * @param data
 */
export function getCategoryList(data) {
  return request({
    url: `${cloud.mall}/tMgdCategory/list`,
    method: 'get',
    params: data
  })
}

/**
 * @description: 商品详情 /goods/detail
 * @param data
 */
export function GoodsDetail(data) {
  return request({
    url: `${cloud.mall}/goods/detail`,
    method: 'get',
    params: data
  })
}



/**
 * @description: 编辑商品 /goods/update
 * @data
 */
export function EditGoods(data) {
  return request({
    url: `${cloud.mall}/goods/update`,
    method: "post",
    data,
  });
}

/**
 * @Description: 删除商品 /goods/deleteByIds
 * @param data
 */
export function deleteGoods(data) {
  return request({
    url: `${cloud.mall}/goods/deleteByIds`,
    method: 'post',
    data
  })
}

/**
 * @Description: 导出 /goods/list/export
 * @param data
 */
export function ExportData(data) {
  return request({
    url: `${cloud.mall}/goods/list/export`,
    method: 'get',
    params: data,
    responseType: 'arraybuffer'
  })
}


/**
 * @Description: 导出 /tModOrder/list/export
 * @param data
 */
export function ExportOrderData(data) {
  return request({
    url: `${cloud.mall}/tModOrder/list/export`,
    method: 'get',
    params: data,
    responseType: 'arraybuffer'
  })
}